package com.itxx.thread5;

public class TicketDemo implements Runnable {
    private int sticket = 100;

    @Override
    public void run() {
        while (true) {
            if (sticket > 0) {
                System.out.println(Thread.currentThread().getName() + "正在卖" + sticket + "张票");
                sticket--;
            } else {
                break;
            }
        }
    }
}
class Demo {
    public static void main(String[] args) {
        TicketDemo tt = new TicketDemo();
        Thread t1 = new Thread(tt, "窗口1");
        Thread t2 = new Thread(tt, "窗口2");
        Thread t3 = new Thread(tt, "窗口3");
        t1.start();
        t3.start();
        t2.start();
    }
}

